package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	// mutli array
	var arr [2][3]int

	fmt.Println(arr) // [[0 0 0] [0 0 0]]

	for i := 0; i < len(arr); i++ {
		fmt.Println(arr[i])
		// [0 0 0]
		// [0 0 0]
	}

	for i := 0; i < len(arr); i++ {
		for j := 0; j < len(arr[0]); j++ {
			fmt.Print(arr[i][j], " ")
		}
		fmt.Println()
	}
	// 0 0 0
	// 0 0 0

	fmt.Println("---------------")

	var arr1 [3][3]int = [3][3]int{
		{1, 2, 3},
		{4, 5, 6},
		{7, 8, 9}, // ','有则'}'可换行，否则不能换行
	}
	for i := 0; i < len(arr1); i++ {
		fmt.Println(arr1[i])
	}

	fmt.Println("----------------")

	var arr2 [3][5]int
	rand.Seed(time.Now().UnixNano())
	for i := 0; i < len(arr2); i++ {
		for j := 0; j < len(arr2[i]); j++ {
			arr2[i][j] = rand.Intn(100) + 1
		}
	}

	for i := 0; i < len(arr2); i++ {
		var sum = 0
		fmt.Println(arr2[i])
		for j := 0; j < len(arr2[0]); j++ {
			sum += arr2[i][j]
		}
		fmt.Printf("%d class sum is %d, average is %.2f\n\n", i+1, sum, float64(sum)/float64(len(arr2[i])))
	}

}
